import { _decorator, Component, director, EventKeyboard, find, Input, input, Node, ProgressBar } from 'cc';
import { defined } from '../hyxh/core/Defined';
import { SecenesManager } from './SecenesManager';
const { ccclass, property } = _decorator;

@ccclass('StartingController')
export class StartingController extends Component {
    start() {
        let that = this;
        /**
         * 加载资源， 
         * 用于显示进度条
         */ 
        let gameResourceManager = SecenesManager.getInstance();
        if (!defined(gameResourceManager) ){
            Error("Game System resources tools is null!");
        }
        gameResourceManager.loadResources('config/hxpath', (totalCount, count) => {
            let bar = find('Canvas/loadedProcessBar').getComponent(ProgressBar);
            if (defined(bar)) {
                bar.progress = count / totalCount;
            }
        },
        () => {
            that.node.active = false;
            director.loadScene('scenes/gamehome', () => {
                const scene = find('scenes/gamehome');
                if (defined(scene)) {
                    scene.active = true;
                }
            })
        })
    }
}


